package de.fhaugsburg.games.boardgames.scrabble.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.List;

import javax.swing.JPanel;

import de.fhaugsburg.games.boardgames.scrabble.IScrabbleEngine;
import de.fhaugsburg.games.boardgames.scrabble.gui.GLetterPiece.GLetterState;
import de.fhaugsburg.games.boardgames.scrabble.scrabbleboard.LetterPiece;

public class GLetterBar extends JPanel {

	
	private static final int MAX_PIECES = IScrabbleEngine.MAX_PIECES; 
	
	
	private IScrabbleEngine engine;
	private GLetterPiece[] letterPiece = new GLetterPiece[MAX_PIECES];
	
	
	
	public GLetterBar(IScrabbleEngine engine) {
		this.engine = engine;
		
		setLayout(new GridLayout(1, MAX_PIECES));
//		revalidate();
//		setSize(500, 200);
		setPreferredSize(new Dimension(400,32));
	}

	
	public void showPieces(List<LetterPiece> letterPieces){
		removeAll();
		int i=0;
		for (LetterPiece piece : letterPieces){
			letterPiece[i] = new GLetterPiece(piece, GLetterState.BAR);
			add(letterPiece[i]);
			i++;
		}
		repaint();
	}
	
	
	
}
